import aiohttp

from config import ZHUQUE_COOKIE, ZHUQUE_CSRF
import logging

logger = logging.getLogger("main")
# 配置区，运行前填好配置
cookie_headers = {
    "Cookie": ZHUQUE_COOKIE,
    "X-Csrf-Token": ZHUQUE_CSRF,
    "referrer": "https://zhuque.in/bonus/shopping/backpack",
}


async def f(id, num):
    url = "https://zhuque.in/api/mall/recycleMagicCard"
    data = {"id": id}

    async with aiohttp.ClientSession() as session:
        for i in range(num):
            async with session.post(url, headers=cookie_headers, json=data) as response:
                if response.status == 200:
                    ret = await response.json()
                    logger.info(ret)
                else:
                    logger.error(f"Error: {response.status} {await response.text()}")
                    return None
